package uk.co.cocking.getinline2.e2e.restlet.test;

import uk.co.cocking.getinline2.builder.Builder;
import uk.co.cocking.getinline2.exceptions.EnvironmentException;
import uk.co.cocking.getinline2.pipeline.Consumer;
import uk.co.cocking.getinline2.pipeline.io.StringLineWriter;
import uk.co.cocking.getinline2.restlet.RestfulServer;

public class BlogLogger {
	
	private RestfulServer server = new RestfulServer(8182);

	public void run() throws Exception {
		server.run();
	}

	public void build(StringLineWriter out) throws EnvironmentException {
		Consumer<String> pipeline = Builder.SCB.
			stringLineWriter(out).
			build();
		server.attachConsumer("/strings", pipeline);
	}
	
	public void buildWritingToFile(String fileName) throws EnvironmentException {
		Consumer<String> pipeline = Builder.SCB.
		fileWriter(fileName).
		build();
		server.attachConsumer("/strings", pipeline);
	}
	
	public static void main(String[] args) throws Exception {
		BlogLogger blogLogger = new BlogLogger();
		blogLogger.buildWritingToFile("test/bl.out");
		blogLogger.run();
	}

}


